<?php

use think\facade\Route;

// 试卷分类
Route::group('admin/paper/category', function () {
    Route::get('/list$', 'getList'); // 课程分类列表
    Route::post('/create$', 'createCategory'); // 添加课程分类
    Route::put('/<id>/edit', 'editCategory')->pattern(['id' => '\d+']); // 编辑课程分类
    Route::delete('/<id>/delete', 'deleteCategory')->pattern(['id' => '\d+']); // 删除课程分类

})->prefix('\app\exam\service\admin\PaperCategory@')->middleware(['adminRoute']);

// 试卷
Route::group('admin/paper', function () {
    Route::get('list', 'index'); // 列表
    Route::get('create', 'create'); // 新增 - 页面
    Route::get('config', 'config'); // 配置
    Route::post('config', 'config'); // 配置
    // 新增固定试卷
    Route::post('settled/create', 'createSettled');
    // 新增随机试卷
    Route::post('random/create', 'createRandom');
    //
    // 编辑指定字段
    Route::put('<id>/edit/<field>$', 'editField')->pattern(['id' => '\d+', 'field' => '[a-zA-Z_]+']);
    // 删除试卷
    Route::delete('<id>/delete', 'delete')->pattern(['id' => '\d+']); // 删除
    // 固定卷
    Route::group('settled/<id>', function () {
        Route::get('edit', 'editSettled'); // 修改 - 页面
        Route::put('edit', 'editSettled'); // 修改 - 提交
    })->pattern(['id' => '\d+']);
    // 随机卷
    Route::group('random/<id>', function () {
        Route::get('edit', 'editRandom'); // 修改 - 页面
        Route::put('edit', 'editRandom'); // 修改 - 提交
    })->pattern(['id' => '\d+']);

    // 详情
    Route::get('<id>/info', 'info')->pattern(['id' => '\d+']);
    // 基本详情
    Route::get('<id>/base/info', 'baseInfo')->pattern(['id' => '\d+']);
    // 批量删除
    Route::delete('deletes/<ids>', 'deletes')->pattern(['ids' => '[\d,]+']);// 批量删除
    // 导出
    Route::post('<id>/export', 'export')->pattern(['id' => '\d+']);
})->prefix('\app\exam\service\admin\Paper@')->middleware(['adminRoute']);

// 派发考试
Route::group('admin/paper/<paper_id>/student', function () {
    // 学员列表
    Route::get('list', '@list');
    // 添加学员
    Route::post('create', '@created');
    // 导入学员
    Route::post('import', '@import');
    // 批量删除
    Route::delete('<ids>', '@deletes')->pattern(['ids' => '[\d,]+']);// 批量删除
    // 成绩
    Route::get('<user_id>/record', '@record')->pattern(['user_id' => '\d+']);
})->prefix('\app\exam\service\admin\PaperStudent')->pattern(['paper_id' => '\d+'])->middleware(['adminRoute']);

// 试卷设置
Route::group('admin/paper/settings', function () {
    // 获取
    Route::get('$', '@get');
    // 设置
    Route::post('$', '@set');
})->prefix('\app\exam\service\admin\PaperConfig')
    ->middleware(['adminRoute']);
// 试卷分享配置
Route::group('admin/paper/share/settings', function () {
    // 获取
    Route::get('$', '@get');
    // 设置
    Route::post('$', '@set');
})->prefix('\app\exam\service\admin\PaperShareConfig')
    ->middleware(['adminRoute']);